<template>
	<view>
		<uni-nav-bar left-icon="arrowthinleft" title="填写简历" :border="false" :fixed="true" bg="bg-fff" color="#333"
			@clickLeft="goBack()"></uni-nav-bar>
		<view class="w100 bg-f7f7f7" style="height: 10rpx;"></view>	
		<view class="padding-x-24 padding-y-10 flex align-center justify-between solid-bottom">
			<view class="fs-26 color-333">标题<text class="color-zhuse">*</text></view>
			<input type="text" v-model="subInfo.title" class="fs-26 color-aaa flex1 text-right h40" placeholder="请输入标题">
		</view>
		<view class="padding-x-24 padding-y-10 flex align-center justify-between solid-bottom">
			<view class="fs-26 color-333">姓名<text class="color-zhuse">*</text></view>
			<input type="text" v-model="subInfo.name" class="fs-26 color-aaa flex1 text-right h40" placeholder="请输入姓名">
		</view>
		<view class="padding-x-24 padding-y-10 flex align-center justify-between solid-bottom ">
			<view class="fs-26 color-333">性别<text class="color-zhuse">*</text></view>
			<picker  :range="sexArr" @change="checkSex" :value="sexIndex">
				<view class="fs-26 color-666 h40" style="line-height: 80rpx;">{{sexArr[sexIndex] || '请选择性别'}}</view>
			</picker>
			<!-- <input type="text" v-model="subInfo.sex"  class="fs-26 color-aaa flex1 text-right " placeholder="请输入性别"> -->
		</view>
		<view class="padding-x-24 padding-y-10 flex align-center justify-between solid-bottom">
			<view class="fs-26 color-333">参加工作时间<text class="color-zhuse">*</text></view>
			<picker mode=date @change="checkTime" fields=month :value="subInfo.job_start_time">
				<view class="fs-26 color-666 h40" style="line-height: 80rpx;">{{subInfo.job_start_time || '请选择参加工作时间'}}</view>
			</picker>
			<!-- <input type="text" v-model=""  class="fs-26 color-aaa flex1 text-right " placeholder="请输入参加工作时间"> -->
		</view>
		<view class="padding-x-24 padding-y-10 flex align-center justify-between solid-bottom">
			<view class="fs-26 color-333">电话<text class="color-zhuse">*</text></view>
			<input type="text" v-model="subInfo.mobile"  class="fs-26 color-aaa flex1 text-right h40" placeholder="请输入电话">
		</view>
		<view class="padding-x-24 padding-y-10 flex align-center justify-between solid-bottom">
			<view class="fs-26 color-333">出生日期<text class="color-zhuse">*</text></view>
			<picker mode=date @change="checkBirth" fields=month :value="subInfo.birth">
				<view class="fs-26 color-666 h40" style="line-height: 80rpx;">{{subInfo.birth || '请选择出生日期'}}</view>
			</picker>
			<!-- <input type="text" v-model="subInfo."  class="fs-26 color-aaa flex1 text-right h40" placeholder="请输入"> -->
		</view>
		<view class="padding-x-24 padding-y-10 flex align-center justify-between solid-bottom">
			<view class="fs-26 color-333">学历<text class="color-zhuse">*</text></view>
			<picker  :range="educationArr" @change="checkEducation" :value="educationIndex">
				<view class="fs-26 color-666 h40" style="line-height: 80rpx;">{{educationArr[educationIndex] || '请选择学历'}}</view>
			</picker>
			<!-- <input type="text" v-model="subInfo.education"  class="fs-26 color-aaa flex1 text-right h40" placeholder="请输入"> -->
		</view>
		<view class="padding-x-24 padding-y-10 flex align-center justify-between solid-bottom">
			<view class="fs-26 color-333">毕业院校<text class="color-zhuse">*</text></view>
			<input type="text" v-model="subInfo.school"  class="fs-26 color-aaa flex1 text-right h40" placeholder="请输入毕业院校">
		</view>
		<view class="padding-x-24 padding-y-10 flex align-center justify-between solid-bottom">
			<view class="fs-26 color-333">个人优势<text class="color-zhuse">*</text></view>
			<input type="text" v-model="subInfo.goodness"  class="fs-26 color-aaa flex1 text-right h40" placeholder="请输入个人优势">
		</view>
		<view class="padding-x-24 padding-y-10 flex align-center justify-between solid-bottom">
			<view class="fs-26 color-333">期望薪资<text class="color-zhuse">*</text></view>
			<input type="text" v-model="subInfo.income"  class="fs-26 color-aaa flex1 text-right h40" placeholder="请输入期望薪资">
		</view>
		<view class="padding-x-24 padding-y-10">
			<view class="fs-26 color-333">工作经历<text class="color-zhuse">*</text></view>
			<textarea v-model="subInfo.work_experience" placeholder="请输入工作经历" style="height: 200rpx;border: 1rpx solid #efefef;width: 92%;"  class="fs-26 color-aaa padding-24  margin-top-30"/>
		</view>
		
		<view class="padding-x-60 margin-y-48 padding-bottom-30">
			<view v-if="!hasSet" @tap="submit()" class="callBtn color-fff radius60 h40 fs-28 text-center">确定</view>
			<view v-else @tap="submit()" class="callBtn color-fff radius60 h40 fs-28 text-center">修改</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				hasSet:false,
				subInfo:{
					title:"",
					name:"",
					sex:"",
					job_start_time:"",
					mobile:"",
					birth:"",
					education:"",
					school:"",
					goodness:'',
					income:'',
					work_experience:'',
				},
				sexArr:['男','女'],
				sexIndex:-1,
				educationArr:['小学','初中','高中','大专','本科','研究生','硕士','博士'],
				educationIndex:-1,
			}
		},
		onLoad() {
			this.init()
		},
		methods:{
			init(){
				var that = this;
				this.$api.get_resume().then(res=>{
					if(res.code == 1){
						if(res.data){
							this.hasSet = true;
							this.subInfo.title = res.data.title;
							this.subInfo.name = res.data.name;
							this.subInfo.sex = res.data.sex;
							this.subInfo.job_start_time = res.data.job_start_time;
							this.subInfo.mobile = res.data.mobile;
							this.subInfo.birth = res.data.birth;
							this.subInfo.education = res.data.education;
							this.subInfo.school = res.data.school;
							this.subInfo.goodness = res.data.goodness;
							this.subInfo.income = res.data.income;
							this.subInfo.work_experience = res.data.work_experience;
							this.sexArr.forEach(function(item,index){
								if(that.subInfo.sex == item){
									that.sexIndex = index
								}
							})
							
							this.educationArr.forEach(function(item,index){
								if(that.subInfo.education == item){
									that.educationIndex = index
								}
							})
						}
					}
				})
			},
			submit(){
				this.$api.add_resume(this.subInfo).then(res=>{
					this.$msg(res.msg)
					if(res.code == 1){
						setTimeout(()=>{
							uni.navigateBack()
						},400)
					}
				})
			},
			// 选择性别
			checkSex(e){
				this.sexIndex = e.detail.value;
				this.subInfo.sex = this.sexArr[this.sexIndex]
			},
			// 工作时间
			checkTime(e){
				this.subInfo.job_start_time = e.target.value
			},
			// 出生日期
			checkBirth(e){
				this.subInfo.birth = e.target.value
			},
			// 学历
			checkEducation(e){
				this.educationIndex = e.detail.value;
				this.subInfo.education = this.educationArr[this.educationIndex]
			},
		}
	}
</script>

<style lang="scss" scoped>
	.callBtn{
		width: 100%;height: 80rpx;line-height: 80rpx;border-radius: 60rpx; background: linear-gradient(to bottom,#FDA730,#FE810A);
	}
</style>
